
       <?php
        include("fachadaBD.php");
        include("top.php");
        include("left.php");
        $f = new fachadaBD();
        $marcas = $f->obtenerMarcas();
        $f->cerrar();
       ?>
      
	<div id="contentC">
	  <div class="center">
	    <h1>Aqui va el contenido</h1><br />

	  </div>
		<div id= "contenido">

        <form name = "catalogo" action="catalogo.php" method="GET">
            <table>
                <tr><td>Marca</td><td><SELECT name="marca" >
                                        <OPTION VALUE="">
                                        <?=$marcas?></OPTION>
                                        <option VALUE="todas">
                                        Todas</option>
                                        </SELECT> </td>
                
                
                    <td>Tipo de Equipo</td><td><SELECT name="tipo" >
                                        <option VALUE=1>
                                        Laptop</option>
                                        <option VALUE=2>
                                        Minilaptop</option>
                                        <option VALUE=0>
                                        Todos</option>
                    </SELECT></td>
                    <td>&nbsp;&nbsp;Ver</td><td><SELECT name="num" >
                                        <option VALUE=15>
                                        15</option>
                                        <option VALUE=20>
                                        20</option>
                                        <option VALUE=25>
                                        25</option>
                    </SELECT> por p&aacute;gina</td>
                    <td>&nbsp;&nbsp;<input type="submit" value="buscar" name="buscar" ></td>
                    
                </tr>
            </table>
        </form>


        
        <?php

        

        $f = new fachadaBD();
        $limit = $_GET["num"];


        $total_results = $f->listarTodos($_GET["marca"],$_GET["tipo"]);
        if($limit != 0){
            $total_pages = ceil($total_results / $limit);//total number of pages
        
        $page = $_GET["page"];
        if (empty($page))
            {
		$page = "1"; //default page if none is selected
            }
        $offset = ($page - 1) * $limit; //starting number for displaying results out of DB

        $lista = $f->listarTodoslim($limit, $offset,$_GET["marca"],$_GET["tipo"]);

        $aux = $offset + 1;
        $aux2 = $offset + mysql_num_rows($lista);
                // This is the Previous/Next Navigation
        }
        if($aux2){
        echo "<font face=Verdana size=1>";
        echo "$aux-$aux2 de $total_results &nbsp;&nbsp;"; // total pages
        if ($page != 1)
        {
            echo "<a href=$PHP_SELF?page=1&marca=".$_GET["marca"]."&num=".$_GET["num"]."><< Primera</a>&nbsp;&nbsp;&nbsp;"; // First Page Link
            $prevpage = $page - 1;
            echo "&nbsp;<a href=$PHP_SELF?page=$prevpage&marca=".$_GET["marca"]."&num=".$_GET["num"]."><<</a>&nbsp;"; // Previous Page Link
        }
    	if ($page == $total_pages)
			{
      			$to = $total_pages;
    		}
		elseif ($page == $total_pages-1)
			{
      			$to = $page+1;
    		}
		elseif ($page == $total_pages-2)
			{
     		 	$to = $page+2;
    		}
		else
			{
      			$to = $page+3;
    		}
    	if ($page == 1 || $page == 2 || $page == 3)
			{
      			$from = 1;
    		}
		else
			{
      			$from = $page-3;
    		}

        for ($i = $from; $i <= $to; $i++){
            if ($i == $total_results) $to=$total_results;
            if ($i != $page){
		echo "<a href=$PHP_SELF?showold=yes&page=$i&marca=".$_GET["marca"]."&num=".$_GET["num"].">$i</a>";
		}
            else{
		echo "<b><font face=Verdana size=2>[$i]</font></b>";
		}
            if ($i != $total_pages)
		echo "&nbsp;";
            }
        if ($page != $total_pages){
            $nextpage = $page + 1;
            echo "&nbsp;<a href=$PHP_SELF?page=$nextpage&marca=".$_GET["marca"]."&num=".$_GET["num"].">>></a>&nbsp;"; // Next Page Link
            echo "&nbsp;&nbsp;&nbsp;<a href=$PHP_SELF?page=$total_pages&marca=".$_GET["marca"]."&num=".$_GET["num"].">&Uacute;ltima >></a>"; // Last Page Link
        }
        echo "</font>";
        }

        echo "<table>";
            if ($lista) {
                while ($row=mysql_fetch_array($lista) ) {
                    $id=$row["MODELO"];
                    echo "<tr> <td> <a href=\"especificacion.php?modelo=".$row["MODELO"]."\"><img src = \"".$row["IMAGENGRANDE"]."\" ></a> </td>";
                    echo "<td><b>".$id."</b> <font color = x1589FF>" .$row["PROCESADOR"].",".$row["MEMORIA"]." GB RAM, ".$row["DISCO"]." GB<br>disco duro";

                    if ($row["WEBCAM"]) {
                        echo ", Webcam ";
                    }

                    $unid = $row["UNIDADLECTURA"];
                    if ($unid) {

                        echo ", Grabador DVD y CD";
                        if ($unid == "CD/DVD-RW CON LIGHTSCRIBE") {
                            echo " con lightscribe";
                        }

                    }

                    echo ",<br> ".$row["SISTEMA"];

                    echo ".<br></font>
                      ".$row["DESCRIPCION"]."<br><b><font color = \"red\">".$row["GARANTIA"]." env&iacute;o ".$row["ENVIO"]."</b></font>";
                    $marca = $f->obtenerImagenMarca($row["MARCA"]);
                    $aux = mysql_fetch_array($marca);
                    echo "<br><img width=\"45\" src = \"".$aux["IMAGEN"]."\" > Mas info agregar a carrito <font color = \"#F62817\">Bsf:</font> <font size = \"4\" color = \"#F62817\">".$row["PRECIO"]."</font>";
                    echo "</td>";
                    echo "<td><font size = \"1\"><font style=\"BACKGROUND-COLOR: #BDBDBD\" color = \"#FFFF00\" >Medios de entrega</font><br>
                          Retiro Personal<br>
                          Env&iacute;o v&iacute;a: <img src = \"images/catalogo/mrw.jpg\" > <img src = \"images/catalogo/zoom.jpg\" > <br>
                          <font style=\"BACKGROUND-COLOR: #BDBDBD\" color = \"#FFFF00\">Medios de Pago:</font><br>
                          Transferencia<br>
                          Deposito<br>
                          Tarjeta de cr&eacute;dito <img src = \"images/catalogo/visa.jpg\" > <img src = \"images/catalogo/mC.jpg\" ></font></td>";

                    echo "</tr>";
                    echo "<tr bgcolor = \"#F0F0F0\"><td COLSPAN=3><br></td></tr>";

                }
            }

        
        echo "</table>";

        $f->cerrar();
        ?>

        </div>
</div>
<?php include("rightbottom.php"); ?>


